package com.hxkj.controller.wechat;

import com.hxkj.domain.po.AppletClassify;
import com.hxkj.domain.po.AppletClassifyTree;
import com.hxkj.domain.po.Column;
import com.hxkj.service.wechat.AppletClassifyService;
import com.platform.common.dispatcher.util.ResultStructUtils;
import com.platform.common.domain.result.ResultMessageStruct;
import com.platform.common.domain.result.ResultPageStruct;
import com.platform.common.domain.to.PageTo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;

/**
 * @ClassName AppletClassifyController
 * @Description TODO
 * @Author Mr.zheng
 * @Date 2018/6/11 11:40
 * @Version 1.0
 */
@RestController
@RequestMapping("/classify")
public class AppletClassifyController {

    @Autowired
    AppletClassifyService appletClassifyService;


    /**
     * @author Mr.zheng
     * @Description saveClassify 新增文章分类
     * @Date 11:54 2018/6/11
     * @Param [appletClassify]
     * @return com.platform.common.domain.result.ResultMessageStruct
     **/
    @RequiresPermissions("classify:add")
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public void saveClassify(@ModelAttribute AppletClassify appletClassify) throws Exception{
        appletClassifyService.saveClassify(appletClassify);
    }

    /**
     * @author Mr.zheng
     * @Description getClassifyList 获取文章分类列表
     * @Date 12:42 2018/6/11
     * @Param [parameterDataStruct]
     * @return java.util.concurrent.Callable<com.platform.common.domain.result.ResultPageStruct<com.hxkj.domain.po.AppletClassify>>
     **/
    @RequiresPermissions("classify:view")
    @RequestMapping(value = "/getlist", method = RequestMethod.POST)
    public Callable<ResultPageStruct<AppletClassify>> getClassifyList(@ModelAttribute AppletClassify appletClassify, @ModelAttribute PageTo pageParam) throws Exception{
        return () -> appletClassifyService.getClassifyList(appletClassify,pageParam);
    }
    /**
     * @author Mr.zheng
     * @Description getClassifyList 获取显示状态的文章分类树状列表
     * @Date 12:42 2018/6/11
     * @Param [parameterDataStruct]
     * @return java.util.concurrent.Callable<com.platform.common.domain.result.ResultPageStruct<com.hxkj.domain.po.AppletClassify>>
     **/
    @RequiresPermissions("classify:view")
    @RequestMapping(value = "/getshowlisttree", method = RequestMethod.POST)
    public Callable<List<AppletClassifyTree>> getShowClassifyTreeList(@ModelAttribute AppletClassify appletClassify) throws Exception{
        return () -> appletClassifyService.getShowClassifyTreeList(appletClassify);
    }

    /**
     * @author Mr.zheng
     * @Description getClassifyTreeList 获取文章分类树形结构
     * @Date 12:43 2018/6/11
     * @Param [appletClassify]
     * @return java.util.concurrent.Callable<com.platform.common.domain.result.ResultMessageStruct>
     **/
    @RequiresPermissions("classify:view")
    @RequestMapping(value = "/getlisttree", method = RequestMethod.POST)
    public Callable<List<AppletClassifyTree>> getClassifyTreeList(@ModelAttribute AppletClassify appletClassify) throws Exception{
        return () -> appletClassifyService.getClassifyTreeList(appletClassify);
    }

    /**
     * @author Mr.zheng
     * @Description modifyClassify 修改文章分类
     * @Date 12:43 2018/6/11
     * @Param [appletClassify]
     * @return java.util.concurrent.Callable<com.platform.common.domain.result.ResultMessageStruct>
     **/
    @RequiresPermissions("classify:modify")
    @RequestMapping(value = "/modify", method = RequestMethod.POST)
    public void modifyClassify(@ModelAttribute AppletClassify appletClassify) throws Exception{
        appletClassifyService.modifyClassify(appletClassify);
    }

    /**
     * @author Mr.zheng
     * @Description removeClassify 删除文章分类
     * @Date 12:46 2018/6/11
     * @Param [appletClassify]
     * @return java.util.concurrent.Callable<com.platform.common.domain.result.ResultMessageStruct>
     **/
    @RequiresPermissions("classify:remove")
    @RequestMapping(value = "/remove", method = RequestMethod.POST)
    public void removeClassify(@ModelAttribute AppletClassify appletClassify) throws Exception{
        appletClassifyService.removeClassify(appletClassify);
    }

    /**
     * @author Mr.zheng
     * @Description modifySortNum 分类排序
     * @Date 12:56 2018/6/11
     * @Param [map]
     * @return java.util.concurrent.Callable<com.platform.common.domain.result.ResultMessageStruct>
     **/
    //@RequiresPermissions("classify:sortnum")
    @RequestMapping(value = "/modifysortnum", method = RequestMethod.POST)
    public void modifySortNum(@RequestParam Map<String,Object> map) throws Exception{
        appletClassifyService.modifySortNum(map);
    }
}
